package com.sinosoft.lk.core.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author 绫小路
 * @date 2021/3/13 21:44
 * @description
 */
public class StreamUtils {

  /**
   * 读取文件内容
   * @param filePath
   * @return
   * @throws IOException
   */
  public static String readFileStreamToString(String filePath) throws IOException {
    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuffer result = new StringBuffer();
    String read = null;
    while ((read = reader.readLine()) != null) {
      result.append(read);
      result.append("\n");
    }
    return result == null ? null : result.toString();
  }
}
